#ifndef WIDGET_H
#define WIDGET_H

#include <QMenu>
#include <QWidget>
#include <QNetworkReply>
#include <QLabel>
#include <QPainter>
#include "citycodeutils.h"
#include "day.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Day days[7];
    QList<QLabel *>mDateList;
    QList<QLabel *>mWeekList;
    QList<QLabel *>mIconList;
    QList<QLabel *>mWeaTypeList;
    QList<QLabel *>mAirqList;
    QList<QLabel *>mFxList;
    QList<QLabel *>mFlList;

    Widget(QWidget *parent = nullptr);
    ~Widget();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    bool eventFilter(QObject *watched,QEvent *event) override;
    void initialization();
    void NewparseWeatherJsonData(QByteArray rawData);
    void ChangeUpperWeatherIcon(QString);
    void ChangeDownWeatherIcon(QString str,int i);
    void InitializHTTPLink();
    void InitializeUiData();
public slots:
    void readHttpReply(QNetworkReply *reply);

private slots:
    void on_pushButton_clicked();

    void on_lineEditCity_returnPressed();

private:
    Ui::Widget *ui;
    //右键菜单
    QMenu *menuQuit;
    //鼠标拖动偏移值
    QPoint Offset;
    QNetworkReply *reply;
    //url地址，用于不同cityid拼接
    QString strUrl;
    QNetworkAccessManager *manager;
    CityCodeUtils cityCoudeUtils;
    QMap<QString,QString> mTypeMap;

    void updateUI();
    void drawTempLine(bool);
};
#endif // WIDGET_H
